<?php
/**
 * 会员后台控制器
 * 
 * @version $Id: Account.php 289 2012-05-02 08:40:09Z linsir123 $
 */
class controllerAccount extends UserController 
{
	/**
	 * @var 模型
	 */
	public $mExchange;
	
	/**
	 * @var 模型
	 */
	public $mAccount;
	
	/**
	 * @var 模型
	 */
	public $mProfile;
	
	/**
	 * @var 模型
	 */
	public $mUser;
	
	/**
	 * 构造函数
	 */
	public function __construct()
	{
		parent::__construct();
		
		///
		$this->mAccount = M::account();
		$this->mExchange = M::exchange();
		$this->mProfile = M::profile();
		$this->mUser = M::user();
	}
	
	/**
	 * 提现页面(提现中,或余额不足于进行提现,这两种情况不能进入)
	 */
	public function actionPay()
	{
		$info = $this->mAccount->getInfo();
		if ($info['state'] == 1 || $info['dis'] != 0) 
			$this->r('main');
			
		///
		if (Request::isAjax() && Request::isPost()) {
			$result = $this->mExchange->newOne();
			///
			$this->ajax($result);
		}
		
		///
		View::display('pay');
		View::assign('account', $info);
	}
	
	/**
	 * 账户设置
	 */
	public function actionProfile()
	{
		if (Request::isAjax() && Request::isPost()) {
			$result = $this->mProfile->modifyInfo();
			///
			$this->ajax($result);
		}
		
		///
		View::display('profile');
		View::assignSet(array(
			'curMenu' => 'profile',
			'info' => $this->mProfile->getInfo()
		));
	}
	
	/**
	 * 修改密码
	 */
	public function actionPassword()
	{
		if ($this->mUser->type != "") 
			$this->r('main');
			
		///
		if (Request::isAjax() && Request::isPost()) {
			$result = $this->mUser->modifyPassword();
			///
			$this->ajax($result);
		}
		
		///
		View::display('password');
		View::assign('curMenu', 'password');
	}
}
